<?php
    // estilos -- ver por qué no puedo usar class con un css - otra clase debe estar bloqueandolo
    $tabla_orga_td = 'vertical-align: middle; background-color: transparent; border: 1px;';    

    // imagenes
    $prev_img = $this->Html->image("restaurante/ic_navegar_left.png", array("width" => "32px", "height" => "32px", "id" => "nav_icon_left"));    
    $next_img = $this->Html->image("restaurante/ic_navegar.png", array("width" => "32px", "height" => "32px", "id" => "nav_icon_right"));    
    $prev_img_disabled = $this->Html->image("restaurante/ic_nav_left_disabled.png", array("width" => "32px", "height" => "32px", "id" => "nav_icon_left_disabled"));    
    $next_img_disabled = $this->Html->image("restaurante/ic_navegar_disabled.png", array("width" => "32px", "height" => "32px", "id" => "nav_icon_right_disabled"));    

    $volver_img = $this->Html->image("restaurante/ic_back.png", array("id" => "back_icon"));    
    $nuevo_img = $this->Html->image("restaurante/ic_add.png", array("id" => "add_icon"));    
    $cancel_img = $this->Html->image("restaurante/ic_cancel.png", array("id" => "back_icon"));    
    $save_img = $this->Html->image("restaurante/ic_ok.png", array("id" => "save_icon"));    
    
    $editar_img = $this->Html->image("restaurante/doc_images.png", array("width" => "24px", "height" => "24px"));    
    
?>

<?php   App::uses('CakeTime', 'Utility');
        App::uses('CakeNumber', 'Utility');
?>

<script type="text/javascript">
    $(document).ready(function() {  
        $('#mover').click(function() {  
            return !$('#PedidoRubroId option:selected').remove().appendTo('#PedidoRubroIdSel');  
        });  
        
        $('#quitar').click(function() {  
            return !$('#PedidoRubroIdSel option:selected').remove().appendTo('#PedidoRubroId');  
        });  
        
        $('.datepicker').datepicker({
            format: "dd-mm-yyyy",
            todayBtn: "linked",
            orientation: "bottom right",
            autoclose: true,
            todayHighlight: true
        });
    });  


</script>

<!--- MARCO DE LA PANTALLA ------>
<table><tr><td style="padding: 20px; background: white; border: none;">

<table>
    <tr style="border: 2px;">
        <td style="width: 15%; text-align:right; <?php echo $tabla_orga_td;?>"><?php echo $this->Html->image("restaurante/ic_resto.png", array("width" => "64px", "height" => "64px", "id" => "resto_icon"));?></td>
        <td style="width: 55%; text-align:left; <?php echo $tabla_orga_td;?>"><h1 class="titulo_ventana">RANKING DE PRODUCTOS</h1></td>
        <td style="width: 30%; text-align:right; <?php echo $tabla_orga_td;?>">
            <table>
                <tr><td style="text-align:right; <?php echo $tabla_orga_td;?>"><?php echo 'Usuario: '.$nombre_usuario;?></td></tr>
                <tr><td style="text-align:right; <?php echo $tabla_orga_td;?>"><?php echo $this->Html->link('Cerrar sesión', array("controller"=>"users", "action"=>"logout"), array('title' => 'Cerrar sesión', 'escape' => false));?></td></tr>
            </table>
        </td>
    </tr>      
</table>
<hr>

<!--- CONTROLES Y BOTONERA FILTROS ------>
<?php $options = array(1 => 'Mensual', 2 => 'Diario'); ?>    

<?php echo $this->Form->create('Pedido', array('action'=>'rankproductos')); ?>
<!--- DOBLE LISTA DE SELECCION DE RUBROS --->
<table>
    <tr>
        <td style="width:25%;<?php echo $tabla_orga_td;?>"><?php echo $this->Form->input('rubro_id', array('multiple' => true, 'type' => 'select', 'label' => 'Rubros',)); ?></td>
        <td style="width:5%; text-align:center; <?php echo $tabla_orga_td;?>">
            <table>
                <tr><td style="text-align:center; <?php echo $tabla_orga_td;?>">
                    <?php echo $this->Form->input('', array('type' => 'button', 'id' => 'mover', 'class' => 'boton-mover-derecha')); ?>
                </td></tr>
                <tr><td style="text-align:center; <?php echo $tabla_orga_td;?>">
                    <?php echo $this->Form->input('', array('type' => 'button', 'id' => 'quitar', 'class' => 'boton-mover-izquierda')); ?>
                </td></tr>
            </table>
        </td>
        <td style="width:25%;<?php echo $tabla_orga_td;?>"><?php echo $this->Form->input('rubro_id_sel', array('multiple' => true, 'type' => 'select', 'label' => 'Rubros Seleccionados ',)); ?></td>
        <td style="width:45%;<?php echo $tabla_orga_td;?>"></td>
    </tr>
</table>
<table>
    <tr>
        <td style="width:10%; <?php echo $tabla_orga_td;?>"><?php echo $this->Form->input('fecha_desde', array( 'label' => 'Desde', 'class' => 'form-control datepicker','type' => 'text'));?>     
        <td style="width:5%; <?php echo $tabla_orga_td;?>"></td>
        <td style="width:10%; <?php echo $tabla_orga_td;?>"><?php echo $this->Form->input('fecha_hasta', array( 'label' => 'Hasta', 'class' => 'form-control datepicker','type' => 'text'));?>  
        <td style="width: 37%; <?php echo $tabla_orga_td;?>"></td>
        <td style="width: 7%; text-align:right; <?php echo $tabla_orga_td;?>"><?php echo 'Listar'; ?></td>
        <td style="width: 7%; text-align:left; <?php echo $tabla_orga_td;?>"><?php echo $this->Form->submit('restaurante/ic_search.png',array('class' => 'boton-buscar')); ?> </td>
        <td style="width: 7%; text-align:right; <?php echo $tabla_orga_td;?>"><?php echo 'Limpiar'; ?></td>
        <td style="width: 7%; text-align:left; <?php echo $tabla_orga_td;?>"><?php echo $this->Form->button('', array('type'=>'reset','class' => 'boton-limpiar')); ?></td>   
    </tr>
</table>
<?php echo $this->Form->end(); ?>

<!--- GRILLA ------>
<?php 
//    Debugger::dump($datos_reporte);
    if(isset($datos_reporte)) { 

        // cabecera de la grilla del reporte con las fechas o meses
        echo '<table style="width: 80%; text-align=center;"><tr>';
        echo '<th style="width: 20%;font-size:8pt;">Ranking</th>';
        echo '<th style="width: 60%;font-size:8pt;">Producto</th>';
        echo '<th style="width: 20%;font-size:8pt;">Cantidad</th>';
        echo '</tr>';

        $i = 1;
        foreach ($datos_reporte as $item):
            if ($item['Producto']['id'] != 0) {
                echo '<tr>';
                echo '<td style="width: 20%;font-size:8pt;">'.$i.'</td>';
                echo '<td style="width: 60%;font-size:8pt;">'.$item['Producto']['descripcion'].'</td>';
                echo '<td style="width: 20%;font-size:8pt;">'.$item[0]['cantidad'].'</td>';
                echo '</tr>';
                $i++; 
            }
        endforeach;
        echo '</table>';
    } 
?>
<br>
<table>
    <tr>
        <td style="text-align:left; <?php echo $tabla_orga_td;?>">
            <?php if (isset($datos_reporte)) echo $this->Html->Image('../reportes/rankingproductos', array('escape' => false)); ?>
        </td>
    </tr>
</table>

<!--- BOTONERA ------->
<table>
    <tr>
        <td style="width: 10%; text-align:right; <?php echo $tabla_orga_td;?>"><?php echo 'Volver'; ?></td>
        <td style="width: 10%; text-align:left; <?php echo $tabla_orga_td;?>">
            <?php echo $this->Html->link($volver_img, array("controller"=>"mainmenus", "action"=>"index"), array('class' => 'button', 'title' => 'Volver', 'escape' => false)); ?>
        </td>
        <td style="width: 80%; <?php echo $tabla_orga_td;?>"></td>
    </tr>
</table>

<!-- overlayed element -->
<div id="dialogModal">
     <!-- the external content is loaded inside this tag -->
     <div class="contentWrap"></div>
</div>

<!--- FIN MARCO DE LA PANTALLA ------>
</td></tr></table>
